package com.start.form.engine.core;

import com.start.common.registers.BaseScanPackageRegister;
import com.start.form.engine.core.service.StartFormConfigService;
import com.start.form.engine.core.storage.StartBaseFormStorageEngineService;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

@Slf4j
@Configuration
@MapperScan({"com.start.form.engine.core.mapper.**"})
@ComponentScan({"com.start.form.engine.core.**"})
public class StartFormEngineCoreAutoConfiguration implements BaseScanPackageRegister {
    public StartFormEngineCoreAutoConfiguration() {

    }
    
    @Bean
    @ConditionalOnMissingBean
    public StartFormEngine startFormEngine(StartFormConfigService startFormConfigService, Map<String, StartBaseFormStorageEngineService> storageEngineMap) {
        return new StartFormEngineImpl(storageEngineMap, startFormConfigService);
    }

    @Override
    public String[] getPackages() {
        return new String[]{"com.start.form.engine"};
    }
}
